<extend name="Base/common"/>
<!--<script type="text/javascript" src="/SG_Shopwechat/Public/Home/js/iscroll.js"></script>-->
<block name="TITLE"><title>采购申请</title></block>
<block name="body" >
    <header data-am-widget="header" class="am-header am-header-default am-header-fixed">
        <div class="am-header-left am-header-nav">
            <a href="{:U('Purchase/index')}" class="">
                <i class="am-header-icon am-icon-home" style="font-size: 40px;"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">
                &nbsp;{$title}
            </a>
        </h1>
    </header>
    <div class="" style="margin-top:10px;font-size: 15px;">
        <form class="am-form am-form-horizontal" action="{:U('List/profinish')}" method="POST">
            <div class="am-form-group">
                <label for="proName" class="am-u-sm-3 am-form-label">商品名称</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="proName" id="proName" readonly type="text"  placeholder="输入商品名称" value="{$pro.proName}" required/>
                </div>
            </div>
            <div class="am-form-group">
                <label for="spec" class="am-u-sm-3 am-form-label">单箱规格</label>
                <div class="am-u-sm-3">
                    <input class="am-form-field" name="spec" id="spec" type="hidden"  placeholder="输入单箱规格" value="{$pro.spec}"/>
                    <input class="" name="head" id="head"  type="text" value="{$pro.head}"/>
                </div>
                <label for="spec" class="am-u-sm-1 am-form-label">头</label>
                <div class="am-u-sm-3">
                    <input class="" name="jin" id="jin" type="text"   value="{$pro.jin}"/>
                </div>
                <label for="spec" class="am-u-sm-2 am-form-label">斤</label>
            </div>

            <div class="am-form-group">
                <label for="grossWeight" class="am-u-sm-3 am-form-label">总重量</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="grossWeight" id="grossWeight" type="text"  onblur="getAmount()" placeholder="输入总重量 斤"  />
                </div>
            </div>

            <div class="am-form-group">
                <label for="number" class="am-u-sm-3 am-form-label">采购件数</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="number" id="number" type="text" onblur="getAmount();" placeholder="输入采购件数" />
                </div>
            </div>

            <div class="am-form-group">
                <label for="price" class="am-u-sm-3 am-form-label">单价<span style="color: red;">*</span></label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="price" id="price" type="text"  onblur="getAmount()" placeholder="输入采购单价 元" required/>
                </div>
            </div>

            <div class="am-form-group">
                <label for="boxheavy" class="am-u-sm-3 am-form-label">箱皮重</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="boxheavy" id="boxheavy" type="text" placeholder="输入箱重 斤" />
                </div>
            </div>

            <div class="am-form-group">
                <label for="netWeight" class="am-u-sm-3 am-form-label">每件净重</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="netWeight" id="netWeight" type="text" placeholder="输入单箱净重 斤" />
                </div>
            </div>

            <div class="am-form-group">
                <label for="amount" class="am-u-sm-3 am-form-label">采购总价<span style="color: red;">*</span></label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="amount" id="amount" type="text" placeholder="输入采购总价 元" required/>
                </div>
            </div>

            <div class="am-form-group">
                <label for="boxfee" class="am-u-sm-3 am-form-label">箱费</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="boxfee" id="boxfee" type="text" placeholder="输入每箱箱费 元" />
                </div>
            </div>

            <div class="am-form-group">
                <label for="loss" class="am-u-sm-3 am-form-label">损耗</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="loss" id="loss" type="text" placeholder="输入每箱损耗：5%" />
                </div>
            </div>

            <div class="am-form-group">
                <label for="selflife" class="am-u-sm-3 am-form-label">存放期</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="selflife" id="selflife" type="text" placeholder="输入存放天数"/>
                </div>
            </div>

            <div class="am-form-group">
                <label for="locality" class="am-u-sm-3 am-form-label">产地</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="locality" id="locality" type="text" placeholder="输入产地"/>
                </div>
            </div>

            <div class="am-form-group">
                <label for="shopName" class="am-u-sm-3 am-form-label">商户名称</label>
                <div class="am-u-sm-9">
                    <input class="am-form-field" name="shopName" id="shopName" type="text" value="{$provider|get_provider_name}" placeholder="输入商户名称" />
                    <input type="hidden" name="provider" value="{$provider}" />
                    <input type="hidden" name="batch" value="{$batch}">
                    <input type="hidden" name="pid" value="{$pid}">
                </div>
            </div>
            <div class="am-form-group">
                <div class="am-u-sm-12">
                    <input type="hidden" name="id" value="{$pro.id}" />
                    <button type="submit" id="submitbtn" class="am-btn am-btn-primary am-btn-block">提交至采购单</button>
                </div>
            </div>
        </form>
    </div>
</block>
<block name="script">

    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">

        //自动算出 采购总价 （采购总价 ＝ 采购件数 * 采购单价）
        function getAmount(){
            number = $("#number").val();        //采购件数
            grossWeight = $("#grossWeight").val();        //总重量
            if(grossWeight>0){
                unitCount = grossWeight;
            }else if(number>0){
                unitCount = number;
            }else{
                return false;
            }
            price = $("#price").val();          //采购单价
            if(!price>0){
                return false;
            }
            $("#amount").val(unitCount * price );  //采购总价
        }
        $("#submitbtn").click(function(){
            number = $("#number").val();        //采购件数
            grossWeight = $("#grossWeight").val();        //总重量

            if((number==undefined&&grossWeight==undefined)||(number==""&&grossWeight=="")){
                alert("请输入采购件数或件数");
                return false;
            }
        })
    </script>
</block>
